<?php
namespace app\common\model;
use think\Model;

class PageModel extends Model{
    protected  $name = 'page';
    protected  $pk   = 'page_id';
    
    // 设置json类型字段
    protected $json = ['page','menu'];
    // 设置JSON数据返回数组
    protected $jsonAssoc = true;
    
    public static function onBeforeInsert($model)
    {
        $model->set("create_ip", request()->ip());
    }
    
    public function getNotesAttr($value,$data){
        return UserNotesModel::where(['user_id'=>$data['user_id'],'staff_id'=>$data['staff_id']])->value('notes');
    }
   
}